package com.kk.jwt;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
/**
 * @author : K k
 * @date : 15:38 2020/6/12
 */
@Data
public class JwtUser implements UserDetails {

    private Long id;

    private String username;

    private String password;

    private String avatar;

    private String email;

    private Integer status;


    private Collection<? extends GrantedAuthority> authorities;

    public JwtUser(Long id ,String username, String password, String avatar,String email,Integer status, Collection<? extends GrantedAuthority> authorities) {
        this.id=id;
        this.username = username;
        this.password = password;
        this.avatar=avatar;
        this.email=email;
        this.status = status;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }


    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    // 账户是否未过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    // 账户是否未被锁
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
